/*
 * @Author: taoyuqing
 * @Date: 2022-12-31 20:14:00
 * @Description: 进度条
 */
import 'package:flutter/material.dart';

class VipStep extends StatelessWidget {
  const VipStep({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: _vipList(),
    );
  }

  Widget _verticalLine() {
    return Container(
      margin: EdgeInsets.only(left: 4, right: 4),
      width: 40,
      height: 1,
      color: Colors.white,
    );
  }

  Widget _moneyBag(
      {required String imgPath,
      required String level,
      required String money,
      bool? showLine = true}) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: EdgeInsets.only(left: 8),
          child: Column(
            children: [
              Text(
                level,
                style:
                    TextStyle(color: Colors.white, fontWeight: FontWeight.w800),
              ),
              Text(
                money,
                style: TextStyle(color: Colors.white),
              )
            ],
          ),
        ),
        Row(
          children: [
            Container(
              child: Image.asset(
                imgPath,
                width: 50,
              ),
            ),
            showLine == true ? _verticalLine() : Container()
          ],
        ),
      ],
    );
  }

  List<Widget> _vipList() {
    List list = [
      {'imgPath': 'images/money-bag.png', 'level': 'VIP 0', 'money': 'R\$'},
      {
        'imgPath': 'images/treasure-box.png',
        'level': 'VIP 1',
        'money': 'R\$10'
      },
      {
        'imgPath': 'images/treasure-box.png',
        'level': 'VIP 2',
        'money': 'R\$20'
      },
      {
        'imgPath': 'images/treasure-box.png',
        'level': 'VIP 3',
        'money': 'R\$30'
      },
      {
        'imgPath': 'images/treasure-box.png',
        'level': 'VIP 4',
        'money': 'R\$100'
      }
    ];
    return list.asMap().keys.map((i) {
      return _moneyBag(
          imgPath: list[i]['imgPath'],
          level: list[i]['level'],
          money: list[i]['money'],
          showLine: i != list.length -1);
    }).toList();
  }
}
